package com.dries.portal.module.user.service;

import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
import com.baomidou.mybatisplus.extension.service.IService;
import com.dries.common.api.CommonResult;
import com.dries.portal.module.user.entity.UserEntity;
import com.dries.portal.module.user.form.RegisterForm;
import com.dries.portal.module.user.form.UserLoginForm;
import org.springframework.security.core.userdetails.UserDetails;

/**
 * 用户
 *
 * @author zsy
 * @email samphsanie@gmail.com
 * @date 2020-06-28 17:11:18
 */
public interface UserService extends IService<UserEntity> {

    /**
     * 获取用户信息
     */
    UserDetails loadUserByUsername(String username);
    UserDetails loadUserByOpenId(String openId);

    /**
     * 根据用户ID获取会员
     */
    CommonResult<UserEntity> getUserById(Long userId);
    /**
     * 根据用户名获取会员
     */
    CommonResult<UserEntity> getByUsername(String username);
    /**
     * 获取当前登录会员
     */
    CommonResult<UserEntity> getCurrentUser();
    /**
     * 用户登录
     */
    CommonResult login(UserLoginForm loginForm);
    /**
     * 用户注册
     */
    CommonResult registerUser(RegisterForm registerForm);
    /**
     * 刷新token
     */
    String refreshToken(String token);

    String loginByOpenId(String openId);

    UserEntity getUserByOpenId(String openId);
    /**
     * 微信用户注册
     * @param userInfo
     */
    CommonResult register(WxMaUserInfo userInfo);
}

